package com.cskaoyan.controller.wx.zjh;

import com.cskaoyan.module.bean.BaseRespVo;
import com.cskaoyan.service.wx.zjh.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Description:
 * @Author: 周佳豪
 * @Date: 2022/04/12/9:18
 */
@RestController
@RequestMapping("wx")
public class RegisterController {
    @Autowired
    RegisterService registerService;

    @PostMapping("auth/regCaptcha")
    public BaseRespVo authRegCaptcha(@RequestBody Map map) {
        String mobile = (String) map.get("mobile");
        BaseRespVo baseRespVo = registerService.authRegCaptcha(mobile);
        return baseRespVo;
    }

    @PostMapping("auth/register")
    public BaseRespVo authRegister(@RequestBody Map map) {
        String code = (String) map.get("code");
        String mobile = (String) map.get("mobile");
        String password = (String) map.get("password");
        String username = (String) map.get("username");
        String wxCode = (String) map.get("wxCode");
        BaseRespVo baseRespVo = registerService.authRegister(code,mobile,password,username,wxCode);
        return baseRespVo;
    }

    @PostMapping("auth/reset")
    public BaseRespVo authReset(@RequestBody Map map) {
        String code = (String) map.get("code");
        String mobile = (String) map.get("mobile");
        String password = (String) map.get("password");

        BaseRespVo baseRespVo = registerService.authReset(code, mobile, password);
        return baseRespVo;
    }
}
